<!--
 * @Author: luohan tangli@guokecs.com
 * @Date: 2024-12-19 10:20:11
 * @LastEditors: luohan tangli@guokecs.com
 * @LastEditTime: 2024-12-21 11:07:45
 * @FilePath: \virtual-tour-web\src\views\home\components\UeView.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="ue-view">
    <div id="ue_d" ref="ueRef"></div>
  </div>
</template>

<script setup>
  import { initUePixelStreaming, addEventListener, removeEventListener,initLocalUePixelStreaming } from 'nc-uesdk';
  import { getDistanceType, startListenMessage, cancelWarningInfo } from '../../../utils/ue.js';
  const ueRef = ref(null);
  const emit = defineEmits();
  nextTick(() => {
    const a = initUePixelStreaming('ws://20.55.4.121:8600', ueRef.value);
    // const a = initUePixelStreaming('ws://10.0.0.106:8600', ueRef.value); /*公司环境*/
    // const a = initLocalUePixelStreaming('ws://10.0.0.248:80', ueRef.value);
    // const a = initUePixelStreaming('ws://10.0.0.25:88', ueRef.value);
    addEventListener(a).then((val) => {
      if (val === 'success') {
        console.log('连接成功');
        startListenMessage(handleUIMessage);
        getDistanceType(0);
        cancelWarningInfo(0);
        removeEventListener(a);
      }
    });
  });
  const handleUIMessage = (callbackFunction, data) => {
    console.log('监听ue', data);
    if (data.function == 'getHistory') {
      emit('getHistory');
    } else if (data.function == 'saveDistanceData') {
      emit('saveDistanceData');
    }
    // 根据返回的数据执行一些操作
  };
</script>

<style lang="scss" scoped>
  .ue-view {
    width: 100%;
    height: 100%;
    #ue_d {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
    }
  }
</style>
